package com.atguigu.util;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author hjy
 * @create 2023/3/27 10:12
 */
public class ThreadPoolUtil {
    private static ThreadPoolExecutor threadPoolExecutor;
    public static ThreadPoolExecutor getThreadPoolExecutor(){

        if (threadPoolExecutor==null){
            synchronized (ThreadPoolExecutor.class){
                if (threadPoolExecutor==null){
                    threadPoolExecutor=new ThreadPoolExecutor(4,20,5, TimeUnit.MINUTES,new LinkedBlockingDeque<>());
                }
            }
        }

        return threadPoolExecutor;
    }
}
